<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <ul id="container"></ul>
    <script>
        let ul = document.getElementById('container');
        // 分页， scroll
        // 懒加载
        // 虚拟列表
        // for(i = 0; i < 100000; i++) {
        //     let li = document.createElement('li');
        //     li.appendChild(document.createTextNode(i));
        //     container.appendChild(li)
        // }
        let total = 100000;
        let once = 20;
        // 游戏 requestAnimationFrame 每秒 60次刷新
        let page = total / once;
        let index = 0;

        function loop(curTotal, curIndex) {
            // 最后一页的数据可能小于 once
            let pageCount = Math.min(curTotal, once);
            window.requestAnimationFrame(function() {
                for(let i = 0; i < pageCount; i++) {
                    let li = document.createElement('li');
                    li.innerText = curIndex + i + ":" + (Math.random()*total);
                    ul.appendChild(li);
                }
                loop(curTotal - pageCount,curIndex + pageCount)
            })
        }
        loop(total,index)
    </script>
</body>
</html>